package com.qingcheng.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @ProjectName: qingcheng_parent
 * @ClassName: LoginController
 * @Time: 2019/7/16
 * @Author: zhou24
 * @Description:
 * @Experience:
 */
@RestController
@RequestMapping("/login")
public class LoginController {

	@GetMapping("/username")
    public Map username(){
        String username = SecurityContextHolder.getContext().getAuthentication().getName();
//        String username = "hello";
        if ("anonymousUser".equals(username)){
            username="";
        }
        System.out.println(username);
        Map map=new HashMap();
        map.put("username",username);
        return map;
    }

}
